﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Xml.Serialization;

namespace Gamev1
{
    public class Item : Sprite
    {
        #region Bonus enum
        public enum Bonus
        {
            Health,
            Jump,
            Time
        }
        #endregion

        #region Fields

        public Bonus bonusType;

        #endregion

        public Item()
        {

        }

        public override void collisionWith(Sprite sprite)
        {
            if (sprite is Character)
            {
                Character character = (Character)sprite;
                if (!character.hasBonus)
                {
                    applyBonus(character);
                    canBeRemoved = true;
                }
            }
        }

        #region Methods

        public void applyBonus(Character character)
        {
            if (bonusType == Bonus.Health)
            {
                healthBonus(character);
            }
            else if (bonusType == Bonus.Jump)
            {
                jumpBonus(character);
            }
            else if (bonusType == Bonus.Time)
            {
                timeBonus(character);
            }
        }

        private void jumpBonus(Character character)
        {
            character.JumpHeight -= 5;
            character.hasBonus = true;
        }

        private void healthBonus(Character character)
        {
            character.Health += 25;
        }
        private void timeBonus(Character character)
        {
            character.CurrentTime += 25;
        }

        #endregion
    }
}
